<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <input type="button" id="btn" value="点击加载数据">
    <p id="demo"></p>
    <script src="./jquery-1.12.4.js"></script>
    <script>
    $(function(){
        $("#btn").on('click',function(){
            $.ajax({
                url:'./ceshi.json',
                type:'get',
                dataType:'json',
                data:{},
                beforeSend:function(){
                    alert('请求发起前调用');
                },
                success:function(data){
                    // console.log(data);
                    $('#demo').html(data.name);
                },
                error:function(){
                    console.log('错误的时候调用');
                },
                complete:function(){
                    console.log('响应完成时调用');
                }
            })
        });
    });
    </script>
</body>
</html>